const MYSQLCONFIG = require('../config/mysql-config')

const { Sequelize, DataTypes, Model } = require('sequelize');
const sequelize = new Sequelize(MYSQLCONFIG.DATABASE, MYSQLCONFIG.USER, MYSQLCONFIG.PASSWORD, {
    host: MYSQLCONFIG.HOST,    //数据库地址,默认本机
    port: MYSQLCONFIG.PORT,
    dialect: MYSQLCONFIG.NAME,
    pool: {   //连接池设置
      max: 5, //最大连接数
      min: 0, //最小连接数
      idle: 10000
    },
    define: {
      freezeTableName: true,
      timestamps:false,
      // 识别驼峰命名与下划线对应
      underscored: true
    }
  })

module.exports.sequelize = sequelize;
module.exports.DataTypes = DataTypes;
module.exports.Model = Model;